package array.leetcode.easy;

/**
 * @author bruin_du
 * @description 和为s的两个数字
 * @date 2022/5/26 20:34
 **/
public class Offer57_TwoSum {
    public int[] twoSum(int[] nums, int target) {
        int s = 0,e = nums.length - 1;
        while(s < e){
            int sum = nums[s] + nums[e];
            if(sum > target) e--;
            else if(sum == target) break;
            else s++;
        }
        return new int[]{nums[s],nums[e]};
    }
}
